//
//  YIem_FindViewModel.m
//  B段_开眼
//
//  Created by YIem on 16/4/22.
//  Copyright © 2016年 Howie. All rights reserved.
//

#import "YIem_FindViewModel.h"

@implementation YIem_FindViewModel
+ (void)getDataWithPage:(NSString *)nextPage andUpdate:(BOOL)isUpdate andBlock:(void (^)(NSMutableArray *))tableArr
{
     NSMutableArray *array = [NSMutableArray array];
    NSMutableArray *array1 = [NSMutableArray array];
    NSMutableArray *array2 = [NSMutableArray array];
    NSMutableArray *array3 = [NSMutableArray array];
    
    [CustomerNetWorking connectWithURL:nextPage andUpdate:isUpdate andBlock:^(id response) {
        NSArray *tempArr = [response objectForKey:@"itemList"];
        for (NSInteger i = 0; i < tempArr.count; i++) {
            if (i == 0) {
                
                for (NSDictionary *dic in [[[tempArr objectAtIndex:0] objectForKey:@"data"] objectForKey:@"itemList"]) {
                    
                    YIem_FindCellModelOne *model = [[YIem_FindCellModelOne alloc] init];
                    [model setValuesForKeysWithDictionary:[dic objectForKey:@"data"]];
                    [array1 addObject:model];
                }
            } else if (i == 1) {
                
                
                for (NSDictionary *dic in [[[tempArr objectAtIndex:1]  objectForKey:@"data"] objectForKey:@"pgcList"]) {
                    
                    YIem_FindCellModelTwo *model = [[YIem_FindCellModelTwo alloc] init];
                    
                    [model setValuesForKeysWithDictionary:dic];
                    model.title = [[[tempArr objectAtIndex:i] objectForKey:@"data"] objectForKey:@"title"];
                    
                    
                    [array2 addObject:model];
                }
                
                
                
            } else {
          
                    YIem_FindCellModel *model = [[YIem_FindCellModel alloc] init];
                    
                    [model setValuesForKeysWithDictionary:[tempArr[i] objectForKey:@"data"]];
                    
                    [array3 addObject:model];
                }
 
        }
        
        [array addObject:array1];
        [array addObject:array2];
        [array addObject:array3];
        tableArr(array);
        }];
   
    
    
}
@end
